<?php
/**
 * Created by PhpStorm.
 * User: muhe0
 * Date: 2017/4/18
 * Time: 4:10
 */

namespace VDB\Spider;
use \ArrayObject ;
class Stackable extends  \Threaded{
    public static function instance($data=null){
        if(!is_array($data)){
            return new static();
        }else{
            $re=new static();
            foreach ($data as $key=>$vv){
                @$re[$key]= $vv;
            }
            return $re;
        }
    }
/*	private function toArray(ArrayObject $arrayObject){
		return  $arrayObject->getArrayCopy();
	}*/
	public function getArray($key){
		$d=$this[$key];
		
		if(is_object($d)){
			$dt = array();
			foreach($d as $dk=>$dv){
				$dt[$dk]=$dv ;
			}
			$d= $dt  ;
		}
		if($d==null){
			$d = array();
		}
		return $d ;
	}
}
